Creating an Instance

You have to create an instance of your class before you can connect it to other objects in your interface. How you create an instance of your class depends on whether it has a user interace; that is, whether it inherits from NSView.

To create an instance of your class, do the steps in one of the following sections.

If your class does not inherit from NSView:

If your class does inherit from NSView:

  1. Choose whether to inherit from NSView directly or from a subclass of NSView.

    If you subclass NSView directly, you cannot set that class's attributes in the Inspector panel. If you subclass an NSView subclass (such as NSButton or NSTextField), however, you can still set that class's attributes in the Inspector panel.

  2. From the Views palette, drag the object whose class you're subclassing onto your interface.

    If you're subclassing an NSView subclass (such as NSButton or NSTextField), drag the object that represents that class (that is, the button or the text field) from the palette window onto your interface's window. If you're subclassing NSView directly, drag the CustomView object on the Views palette.

  3. Choose Tools > Instpector, choose Custom Class from the menu at the top of the Inspector, and select your class from the list.
Next Step
Connecting the Actions and Outlets
Main Topic
Importing a Class

© 1999 Apple Computer, Inc.